package yang.VirtualMachine.chapter11.asm;

import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;

public class AddSecurityCheckMethodAdapter extends MethodVisitor {

	public AddSecurityCheckMethodAdapter(MethodVisitor mv) {
		super(Opcodes.ASM5, mv);
	}
	
	@Override
	public void visitCode() {
		Label continueLabel = new Label();
		visitMethodInsn(Opcodes.INVOKESTATIC, "yang/VirtualMachine/chapter11/SecurityChecker"
				, "checkSecurity", "()Z");
		visitJumpInsn(Opcodes.IFNE, continueLabel);
		visitInsn(Opcodes.RETURN);
		visitLabel(continueLabel);
		super.visitCode();
	}
	

}
